﻿@using OrchardCore.ContentManagement
@using OrchardCore.Contents
@inject IAuthorizationService AuthorizationService

@{
    ContentItem contentItem = Model.ContentItem;
    var previewId = Guid.NewGuid();
    var hasPreviewPermission = await AuthorizationService.AuthorizeAsync(User, CommonPermissions.PreviewContent, contentItem);
}

@if (hasPreviewPermission)
{
    <a id="previewButton" target="Preview" class="btn btn-info" href="@Url.Action("Index", "Preview", new { area = "OrchardCore.ContentPreview", id = previewId })">@T["Preview"]</a>
}

<div id="renderPreviewUrl" style="display:none" data-value="@Url.Action("Render", "Preview", new { area = "OrchardCore.ContentPreview" })"></div>
<div id="contentItemType" style="display:none" data-value="@Model.ContentItem.ContentType"></div>
<div id="previewId" style="display:none" data-value="@previewId"></div>
<div id="previewContentItemId" style="display:none" data-value="@Model.ContentItem.ContentItemId"></div>
<div id="previewContentItemVersionId" style="display:none" data-value="@Model.ContentItem.ContentItemVersionId"></div>

<script asp-name="contentpreview-edit" at="Foot"></script>
<script at="Foot" depends-on="contentpreview-edit">
    
$(function () {
//  $(document).on('input', '.content-preview-text', function () {
//    $(document).trigger('contentpreview:render');
//  }).on('propertychange', '.content-preview-text', function () {
//    $(document).trigger('contentpreview:render');
//  }).on('keyup', '.content-preview-text', function (event) {
//    // handle backspace
//    if (event.keyCode == 46 || event.ctrlKey) {
//      $(document).trigger('contentpreview:render');
//    }
//  }).on('change', '.content-preview-select', function () {
//    $(document).trigger('contentpreview:render');
//  });
//});
</script>
 



